package com.hengli.mapper;

import com.github.pagehelper.Page;
import com.hengli.annotation.AutoFill;
import com.hengli.dto.WinePageQueryDTO;
import com.hengli.entity.Wine;
import com.hengli.enumeration.OperationType;
import com.hengli.vo.WineVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface WineMapper {

    /**
     * 根据分类id查询酒品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from winepackage where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 新增酒品
     * @param wine
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Wine wine);

    /**
     * 酒品分页查询
     *
     * @param winePageQueryDTO
     * @return
     */
    Page<WineVO> pageQuery(WinePageQueryDTO winePageQueryDTO);

    /**
     * 根据主键查询酒品
     *
     * @param id
     * @return
     */
    @Select("select * from wine where id = #{id}")
    Wine getById(Long id);

    /**
     * 根据主键删除酒品数据
     *
     * @param id
     */
    @Delete("delete from wine where id = #{id}")
    void deleteById(Long id);

    /**
     * 根据id动态修改酒品数据
     *
     * @param wine
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Wine wine);

    /**
     * 根据分类id查询酒品
     *
     * @param id
     * @return
     */
    List<Wine> list(Integer id);


    /**
     * 根据条件统计酒品数量(工作台使用)
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
